package com.judian.smart.net;

import com.google.gson.JsonObject;
import com.judian.smart.model.ResultInfo;

import java.util.HashMap;

import okhttp3.MultipartBody;
import okhttp3.RequestBody;
import okhttp3.ResponseBody;
import retrofit2.Call;
import retrofit2.http.Field;
import retrofit2.http.FieldMap;
import retrofit2.http.FormUrlEncoded;
import retrofit2.http.GET;
import retrofit2.http.Header;
import retrofit2.http.Headers;
import retrofit2.http.Multipart;
import retrofit2.http.POST;
import retrofit2.http.Part;
import retrofit2.http.Query;
import retrofit2.http.Url;

/**
 * author: Peter
 * date: 2019/08/10 星期六 15:03
 * desc:
 */
public interface IRetrofitApi {

    //---获取云端图片--/Service/ImageService.asmx/getImagesByType
    @GET("Service/ImageService.asmx/getImagesByType")
    @Headers("version:1")
    Class<JsonObject> getImagesByType(@Query("TypeId") int typeId);


    //---获取红外云端下载品牌信息---/Service/InfraWebService.asmx/GetInfraNames
    @GET("Service/InfraWebService.asmx/GetInfraNames")
    @Headers("version:1")
    Call<JsonObject> getInfraName(@Query("PageNum") int pageNum, @Query("PageCount") int pageCount);


    //---获取红外云端下载品牌开关---/Service/InfraWebService.asmx/GetInfraVersions
    @GET("Service/InfraWebService.asmx/GetInfraVersions")
    @Headers("version:1")
    Call<JsonObject> getInfraVersion(@Query("InfraID") int infraId);


    //---获取红外云端下载的代码---/Service/InfraWebService.asmx/GetInfraCodes
    @GET("/Service/InfraWebService.asmx/GetInfraCodes")
    @Headers("version:1")
    Call<JsonObject> getInfraCode(@Query("VersionID") int infraId);


    //---获取串口云端品牌---/Service/ProjectorService.asmx/getProjectors
    @GET("Service/ProjectorService.asmx/getProjectors")
    @Headers("version:1")
    Call<JsonObject> getProjectors(@Query("proType") int proType);


    //---获取串口云端品牌开关---/Service/ProjectorService.asmx/getProjectorVersions
    @GET("Service/ProjectorService.asmx/getProjectorVersions")
    @Headers("version:1")
    Call<JsonObject> getProjectorsVersion(@Query("versionId") int versionId);

    //---获取串口云端品牌开关码(code)---/Service/ProjectorService.asmx/getProjectorCode
    @GET("Service/ProjectorService.asmx/getProjectorCode")
    @Headers("version:1")
    Call<JsonObject> getProjectorsCode(@Query("versionId") int versionId);


    //---获取我的云家庭---/Service/ZunProjectService.asmx/getMyFamily
    @FormUrlEncoded
    @POST("Service/ZunProjectService.asmx/getMyFamily")
    @Headers("version:1")
    Call<JsonObject> getMyFamily(@Field("primaryKey") String primaryKey);


    //---获取指定用户的云家庭---/Service/ZunProjectService.asmx/getClientFamilys
    @FormUrlEncoded
    @POST("Service/ZunProjectService.asmx/getClientFamilys")
    @Headers("version:1")
    Call<JsonObject> getClientFamilys(@Field("UserName") String userName, @Field("PassWord") String pwd);


    /**
     * ---上传当前的家庭---Service/ZunGatewayService.asmx/uploadFamily
     *
     * @param dbFile Name: 专案名称 passWord: 专案密码 primaryKey: 专案所属账号
     */
    @Multipart
    @POST("Service/ZunGatewayService.asmx/uploadFamily")
    @Headers("version:1")
    Call<JsonObject> upLoadFamily(@Part() MultipartBody.Part dbFile, @Part("Name") RequestBody name, @Part("passWord") RequestBody PassWord, @Part("primaryKey") RequestBody PrimaryKey);


    //---删除指定专案---Service/ZunProjectService.asmx/deleteFamily
    @FormUrlEncoded
    @POST("Service/ZunProjectService.asmx/deleteFamily")
    @Headers("version:1")
    Call<JsonObject> deleteFamily(@Field("primaryKey") String primaryKey, @Field("projectKey") String projectKey);


    /**
     * 此接口使用 1168 端口
     * ---下载我的专案---/ImagesFile/save_family/{promaryKey}/{projectKey}.db
     *
     * @Param promaryKey ⬅ 链接拼接 ➡ projectKey
     */
    @GET
    Call<ResponseBody> downMyFamily(@Url() String url);

    //---获取APK地址---
    @GET
    Call<ResponseBody> downloadApk(@Url() String url);


    //---修改指定专案的密码---
    @FormUrlEncoded
    @POST("Service/ZunProjectService.asmx/updateFamily")
    @Headers("version:1")
    Call<JsonObject> modifyFamilyPwd(@Field("ProjectKey") String projectKey, @Field("ProjectPwd") String pwd);

    //---注册账号---
    @FormUrlEncoded
    @POST("Service/UserService.asmx/RaegisterUser")
    @Headers("version:1")
    Call<ResultInfo> registeredUser(@FieldMap() HashMap<String, String> userInfo);

    //---检测APP新版本---
    @GET("announce")
    Call<JsonObject> getApkVersion(@Header("android") int versionCode);

    //---获取最新的APP版本
    @FormUrlEncoded
    @POST("app/version/number")
    Call<JsonObject> getApkVersion(@Field("Type") String apkType);

    @GET
    Call<ResponseBody> downApk(@Url() String url);

    @FormUrlEncoded
    @POST("Service/TransFer/File")
    @Headers("version:1")
    Call<JsonObject> permissionToTransfer(@FieldMap() HashMap<String, String> projectInfo);

}
